package com.zy.mc_module.wheel.recyclerview.divider;

import android.content.Context;
import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.zy.mc_module.utils.SizeUtils;

/**
 * Created on 18/12/28
 * 筛选间距
 */
public class FilterItemDivider extends RecyclerView.ItemDecoration {
    private Context context;

    public FilterItemDivider(Context context) {
        this.context = context;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        int position = parent.getChildAdapterPosition(view);
        outRect.bottom = SizeUtils.dp2px(context, 9);
        if (position % 4 == 0) {
            outRect.right = SizeUtils.dp2px(context, 7.5f);
        } else if (position % 4 == 1) {
            outRect.left = SizeUtils.dp2px(context, 2.5f);
            outRect.right = SizeUtils.dp2px(context, 5f);
        } else if (position % 4 == 2) {
            outRect.left = SizeUtils.dp2px(context, 5f);
            outRect.right = SizeUtils.dp2px(context, 2.5f);
        } else if (position % 4 == 3) {
            outRect.left = SizeUtils.dp2px(context, 7.5f);
        }
    }
}